package work20241203_chap6oop.r_demo15;

/**
 * @author zdl
 * @date 2024/12/5
 */
public class HourlyEmployee extends Employee {
    private double hourlySalary;
    private int hours;

    @Override
    public double getSalary(int month) {
        /*if (this.getMonth() == month) {
            if (getHours() > 160) {
                double s = ((getHours() - 160) * 1.5 * hourlySalary) + (160 * hourlySalary);
                return s + 100;
            } else {
                return hours * hourlySalary + 100;
            }
        } else {
            return hours * hourlySalary;
        }*/
        double s = 0;
        if (hours <= 160) {
            s = ((hours - 160) * 1.5 * hourlySalary) + (160 * hourlySalary);
        } else {
            s = hours * hourlySalary;
        }
        if (this.getMonth() == month) {
            return s + 100;
        }
        return s;
    }

    public HourlyEmployee(double hourlySalary, int hours) {
        this.hourlySalary = hourlySalary;
        this.hours = hours;
    }

    public HourlyEmployee(String name, int month, double hourlySalary, int hours) {
        super(name, month);
        this.hourlySalary = hourlySalary;
        this.hours = hours;
    }

    public double getHourlySalary() {
        return hourlySalary;
    }

    public void setHourlySalary(double hourlySalary) {
        this.hourlySalary = hourlySalary;
    }

    public int getHours() {
        return hours;
    }

    public void setHours(int hours) {
        this.hours = hours;
    }
}
